<div class="standard left large">
<br><br>
<?php

// $this->caseInfo
// $this->caseMerchItems 
// $this->caseServicesItems
// $this->caseCashAdvanceItems

	$case_num = $this->caseInfo['FDMS_case_num'];
	
	$decedent_name = "";
	$decedent_name .= $this->caseInfo['decedent_fname']." ";
	$decedent_name .= $this->caseInfo['decedent_mname']." ";
	$decedent_name .= $this->caseInfo['decedent_lname'];
	
	$arranger_name = $this->caseFDinfo['full_name'];
	
	$funeral_home_name = $this->caseFHinfo['name'];
	
	$choice = $this->caseInfo['choice'];
	$tribute = $this->caseInfo['tribute_chosen'];
	$casket = $this->selections["Casket"]["item_description"];
	$urn = $this->selections["Urn"]["item_description"];
	$vault = $this->selections["Vault"]["item_description"];

	// casket/urn and vault price?
	
	$caterer_name = $this->caseInfo['caterer'];
	$caterer_name = stripslashes($caterer_name);
	$caterer_name = str_replace(":", "", $caterer_name);
	$menu_and_cost = $this->caseInfo['menu'];
	if(!empty($menu_and_cost))
	{
		list($menu, $menu_price) = explode(':', $menu_and_cost);
	}

	// now get menu description
	
	$headcount = $this->caseInfo['headcount'];
	$catering_total = $this->caseInfo['catering_total'];
	if(empty($catering_total)) $catering_total = 0.0;
	$catering_notes = $this->caseInfo['catering_notes'];
	
	$florist_name = $this->caseInfo['florist'];
	$florist_name = stripslashes($florist_name);
	$florist_name = str_replace(":", "", $florist_name);
	$floral_total = $this->caseInfo['floral_total'];

	$arrangements_xml_str = $this->caseInfo['arrangement'];
	$arrangements = array();
	if(!empty($arrangements_xml_str))
	{
		$arrangements_xml = simplexml_load_string( $arrangements_xml_str );
		foreach($arrangements_xml->collection as $collection)
		{
			$arrangement = array();
			$arrangement['name'] = "".$collection->name;
			$arrangement['price'] = "".$collection->price;
			$arrangements[] = $arrangement;
		}
	}	
	
	$floral_total = $this->caseInfo['floral_total'];
	
	if(empty($floral_total)) $floral_total = 0.0;
	$floral_notes = $this->caseInfo['floral_notes'];
?>	
<h1>Case Information:</h1>
<div id="section1">
	<strong>Case#:</strong> <?php echo $case_num?><br>
	<strong>Decedent:</strong> <?php echo $decedent_name?><br>
	<strong>Arranger:</strong> <?php echo $arranger_name?><br>
	<strong>Home:</strong> <?php echo $funeral_home_name?><br>
</div>
<br><br>
<div id="section2">
	<strong>Choice:</strong> <?php echo $choice?><br>
	<?php
	echo "<strong>Tribute Chosen</strong>: $tribute<br>";
	if($choice == "BURIAL") echo "<strong>Casket:</strong> $casket<br>";
	if($choice == "CREMATION") echo "<strong>Urn:</strong> $urn<br>";
	echo "<strong>Vault:</strong> $vault<br>";
	?>
</div>
<br><br>
<div id="section3">
	<h1>Services:</h1>
	<?php
	$servicesTotal = 0.0;
	if($this->caseServicesItems)
	{
 		// loop thru $this->caseServicesItems and write them out in a table
 		$rowclass = 0;
 		echo "<table cellpadding=\"6\" cellspacing=\"4\" style=\"width:100%\" class=\"summarytable\">\n";
 		echo "<tr><th>ID</th><th>CL#</th><th>Description</th><th>Price</th></tr>\n";
 		foreach( $this->caseServicesItems as $item )
 		{
 			echo "<tr class=\"row" . $rowclass . "\">";
 			echo "<td>".$item['price_list_id']."</td>";
 			echo "<td>".$item['line_number']."</td>";
 			echo "<td>".$item['item_description']."</td>";
 			if($item['source'] == "ALACARTE") {
				$amt = 1.0*$item['item_amount'];
				$qty = 1.0*$item['qty'];
				$total = $amt*$qty;
				echo "<td>\$$total</td>";
 			}
 			else {
 				echo "<td>INCLUDED</td>";
 			}
 			echo "</tr>\n";
 			$rowclass = 1 - $rowclass;
 			$servicesTotal += $item['item_amount'];
 		}
 		echo "<tr class=\"row0\"><td colspan=3>Total</td><td>\$$servicesTotal</td></tr>";
 		echo "</table>\n";
	}
	else
	{
 		echo "<em>No services selected for this case</em><br>";
	}
	// services
	?>
	<a href="/index/vasservices/return_page/vasfullsummary">Edit</a>
</div>
<br><br>
<div id="section4">
	<h1>Cash Advances:</h1>
	<?php
	if($this->caseCashAdvanceItems)
	{
		$cashAdvanceTotal = 0.0;
 		// loop thru $this->caseServicesItems and write them out in a table
 		$rowclass = 0;
 		echo "<table cellpadding=\"6\" cellspacing=\"4\" style=\"width:100%\" class=\"summarytable\">\n";
 		echo "<tr><th>ID</th><th>CL#</th><th>Description</th><th>Qty</th><th>Price</th><th>Total</th></tr>\n";
 		foreach( $this->caseCashAdvanceItems as $item )
 		{
 			echo "<tr class=\"row" . $rowclass . "\">";
 			echo "<td>".$item['price_list_id']."</td>";
 			echo "<td>".$item['line_number']."</td>";
 			echo "<td>".$item['item_description']."</td>";
 			echo "<td>".$item['qty']."</td>";
 			if($item['source'] == "ALACARTE") {
	 			echo "<td>\$".$item['item_amount']."</td>";
	 			echo "<td>\$".$item['total']."</td>";
	 		}
	 		else {
	 			echo "<td colspan=2 align=center>INCLUDED</td>";
	 		}
 			echo "</tr>\n";
 			$rowclass = 1 - $rowclass;
 			$cashAdvanceTotal += $item['total'];
 		}
 		echo "<tr class=\"row0\"><td colspan=5>Total</td><td>\$$cashAdvanceTotal</td></tr>";
 		echo "</table>\n";

		$things_to_bring = stripslashes($this->caseInfo['things_to_bring']); 		
 		echo "<table cellpadding=\"6\" cellspacing=\"4\" style=\"width:100%\" class=\"summarytable\">\n";
 		echo "<tr class=\"row0\"><td>Family Reminders</td><td colspan=4><pre>$things_to_bring</pre></td></tr>";
 		echo "</table>\n";
	}
	else
	{
 		echo "<em>No cash advances selected for this case</em><br>";
	}
	?>
</div>
	<a href="/index/vascashadvances/return_page/vasfullsummary">Edit</a>
<br><br>
<div id="section5">
	<h1>Merchandise:</h1>
	<?php
	if($this->caseMerchItems)
	{
		$merchandiseTotal = 0.0;
 		$rowclass = 0;	
 		echo "<table cellpadding=\"6\" cellspacing=\"4\" style=\"width:100%\" class=\"summarytable\">\n";
 		echo "<tr><th>ID</th><th>CL#</th><th>Source</th><th>Description</th><th>Qty</th><th>Price</th><th>Total</th></tr>\n";
 		foreach( $this->caseMerchItems as $item )
 		{
 			echo "<tr class=\"row" . $rowclass . "\">";
 			echo "<td>".$item['price_list_id']."</td>";
 			echo "<td>".$item['line_number']."</td>";
 			echo "<td>".$item['source']."</td>";
 			echo "<td>".$item['item_description']."</td>";
 			echo "<td>".$item['qty']."</td>";
 			if($item['source'] == "ALACARTE") {
	 			echo "<td>\$".$item['item_amount']."</td>";
	 			echo "<td>\$".$item['total']."</td>";
 			}
 			else {
	 			echo "<td colspan=2 align=center>INCLUDED</td>";
 			}
 			echo "</tr>\n";
 			$rowclass = 1 - $rowclass;
 			$merchandiseTotal += $item['total'];
 		}
 		echo "<tr class=\"row0\"><td colspan=6>Total</td><td>\$$merchandiseTotal</td></tr>";
 		echo "</table>\n";
	}
	else
	{
 		echo "<em>No merchandise selected for this case</em><br>";
	}
	?>
</div>
	<a href="/index/vasmementos/return_page/vasfullsummary">Edit</a>
<br><br>
<div id="section6">
 	<h1>Catering:</h1>
<?php
		if($caterer_name == "Choose a caterer")
		{
			$caterer_name = "None chosen";
			$menu = "None chosen";
			$menu_price = "Unknown";
			$catering_total = 0;
		}
		
 		echo "<table cellpadding=\"6\" cellspacing=\"4\" style=\"width:100%\" class=\"summarytable\">\n";
 		echo "<tr class=\"row0\"><td>Caterer:</td><td>$caterer_name</td></tr>";
 		echo "<tr class=\"row1\"><td>Menu:</td><td>$menu</td></tr>";
 		echo "<tr class=\"row0\"><td>Price:</td><td>$menu_price</td></tr>";
 		echo "<tr class=\"row1\"><td>Headcount:</td><td>$headcount</td></tr>";
 		echo "<tr class=\"row0\"><td>Total:</td><td>\$$catering_total</td></tr>";
 		echo "<tr class=\"row1\"><td>Notes:</td><td>$catering_notes</td></tr>";
 		echo "</table>\n";

 ?>
	<a href="/index/vascatering/return_page/vasfullsummary">Edit</a>
</div>
<br><br>
<div id="section7">
 	<h1>Floral:</h1>
 <?php
 	if($florist_name == "Select a florist") $florist_name = "None selected";
 	echo "<table cellpadding=\"6\" cellspacing=\"4\" ";
 	echo "width=\"100%\" class=\"summarytable\">\n";
 	echo "<tr class=\"row0\"><td>Florist:</td><td>$florist_name</td></tr>";
 	echo "<tr class=\"row1\"><td>Notes:</td><td><pre>$floral_notes</pre></td></tr>";
 	echo "<tr class=\"row0\"><td colspan=2>Arrangements:<br>";
 	echo "<table cellpadding=\"6\" cellspacing=\"4\" ";
 	echo "width=\"100%\" class=\"summarytable\">\n";
 	$rowclass = 1;
 	$arrangement_total = 0;
 	if($arrangements != null)
 	{
	 	foreach( $arrangements as $arrangement)
	 	{
	 		echo "<tr class=\"row" . $rowclass . "\">";
	 		echo "<td>".$arrangement['name']."</td>";
	 		echo "<td>".$arrangement['price']."</td>";
	 		echo "</tr>\n";
	 		$rowclass = 1 - $rowclass;
	 		$arrangement_total += $arrangement['price'];
	 	}
 	}
 	else
 	{
 		echo "<tr class=\"row" . $rowclass . "\">";
 		echo "<td colspan=2>No floral arrangements selected</tr>\n";
 	}
# 	$adjusted_total = $arrangement_total;
 	$adjusted_total = $floral_total;
 	echo "</td></tr></table>";
 	echo "<tr class=\"row$rowclass\"><td>Total:</td><td>\$$floral_total</td></tr>";
 	echo "</table>\n";
  ?>
	<!-- add link to /index/vasfloral/return_page/vasfullsummary -->
	<a href="/index/vasfloral/return_page/vasfullsummary">Edit</a>
</div>
<br><br>
<div id="section8">
	<?php
	// grand total
	// $grand_total = $servicesTotal + $cashAdvanceTotal + $merchandiseTotal + $catering_total +
	//	$arrangement_total + $adjustment;
	$grand_total = $servicesTotal + $cashAdvanceTotal + $merchandiseTotal + $catering_total + $floral_total;	
		
		

	$profile = array();
	$profile['total_revenue'] = $grand_total;
	$caseModel = new FDMSCases();
	$results = $caseModel->updateCase( $profile, $case_num );
 	echo "<table cellpadding=\"6\" cellspacing=\"4\" width=\"100%\" class=\"summarytable\">\n";
 	echo "<tr class=\"row0\"><td>Grand Total</td><td><span style=\"text-align:right\">\$$grand_total</span></td></tr>";
 	echo "</table>\n";
	?>
</div>
 

</div>
